<?php
namespace App\Logic;

use Swoft\Auth\Mapping\AccountTypeInterface;
use Swoft\Auth\Bean\AuthResult;
use Swoft\Bean\Annotation\Bean;

/**
 * @Bean()
 */
class AdminNormalAccount implements AccountTypeInterface
{


    const ROLE = 'role';

    /**
     * @throws \Swoft\Db\Exception\DbException
     */
    public function login(array $data) : AuthResult
    {
        $identity = $data['identity'];
        $credential = $data['credential'];
        $result = new AuthResult();
        $result->setExtendedData([self::ROLE => $credential]);
        $result->setIdentity($identity);
        return $result;
    }

    /**
     * @throws \Swoft\Db\Exception\DbException
     */
    public function authenticate(string $identity) : bool
    {
        return $identity;
    }
}